package com.ruoyi.bussiness.controller;

import com.ruoyi.bussiness.domain.Contant;
import com.ruoyi.bussiness.service.ContantService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysDept;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 合同信息(Contant)表控制层
 *
 * @author makejava
 * @since 2025-07-05 11:59:19
 */
@RestController
@RequestMapping("/contant")
public class ContantController extends BaseController {
    /**
     * 服务对象
     */
    @Resource
    private ContantService contantService;

    /**
     * 分页查询
     *
     * @param contant 筛选条件
     * @return 查询结果
     */
    @GetMapping("/list")
    public AjaxResult list(Contant contant)
    {
        List<Contant> contantList = contantService.selectContantList(contant);
        return success(contantList);
    }


    /**
     * 新增数据
     *
     * @param contant 实体
     * @return 新增结果
     */
    @PostMapping
    public ResponseEntity<Contant> add(@Validated @RequestBody Contant contant) {
        contant.setCreateBy(getUsername());
        return ResponseEntity.ok(this.contantService.insert(contant));
    }
    /**
     * 获取流程单详细信息
     */
    @GetMapping(value = "/getInfo")
    public AjaxResult getInfo(String bussinessKey)
    {
        System.out.println("bussinessKey:"+bussinessKey);
        return success( this.contantService.queryById(bussinessKey));
    }

    /**
     * 编辑数据
     *
     * @param contant 实体
     * @return 编辑结果
     */
    @PostMapping("updateContant")
    public AjaxResult updateContant(Contant contant) {
        return success(this.contantService.update(contant));
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping
    public ResponseEntity<Boolean> deleteById(Long id) {
        return ResponseEntity.ok(this.contantService.deleteById(id));
    }

}

